﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;
using TestCommunityMvvmToolkit.Views;

namespace TestCommunityMvvmToolkit
{
    //public partial class MainViewModel : ObservableObject
    public partial class MainViewModel : BindableBase
    {
        public MainViewModel()
        {
            var d1 = new DogViewModel();

            Animals.Add(d1);
            Animals.Add(new CatViewModel());

            selectedAnimal = d1;
        }

        [ObservableProperty]
        private string name = "";

        [ObservableProperty]
        private AnimalBase? selectedAnimal;

        public ObservableCollection<AnimalBase> Animals { get; } = new();

        [ICommand]
        public void ShowMe()
        {
            Name = Path.GetRandomFileName();
            Trace.TraceInformation("Show me." + nameof(ShowMeCommand));
        }

        [ICommand]
        private async Task ShowMe2Async(string name, CancellationToken cancellation)
        {
            await Task.Delay(500, cancellation);
        }
    }
}